let resolve = (value) => {
    // ======新增逻辑======
    // 如果 value 是一个promise，那我们的库中应该也要实现一个递归解析
    if(value instanceof Promise){
        // 递归解析 
        return value.then(resolve,reject)
    }
    // ===================
    if(this.status ===  PENDING) {
      this.status = FULFILLED;
      this.value = value;
      this.onResolvedCallbacks.forEach(fn=>fn());
    }
  }
  
  Promise.prototype.catch = function(errCallback){
    return this.then(null,errCallback)
  }

  Promise.prototype.finally = function(callback) {
    return this.then((value)=>{
      return Promise.resolve(callback()).then(()=>value)
    },(reason)=>{
      return Promise.resolve(callback()).then(()=>{throw reason})
    })  
  }
